<?php
/**
 * Description of AuditController
 * 审核管理
 * @author etpasse
 */
//require_rewrite(MODULE_ROOT."manager/admin/LogManager.class.php");
require_rewrite(ROOT_PATH."data/UserConfig.class.php");
class AuditController extends BaseController {

    private $method;
    public function __construct() {
        parent::__construct();
        //取得页面访问方式
        $this->method = Handler_http::getMethod();
    }

    /**
     * 待审核用户列表
     */
    public function userListAudit(){
        $audituserlist=new AuditModule();
        if($this->method =="POST"){
            $sel['txtusername'] = $_POST['txtUsername'];
            $this->tpl->assign('txtusername', $sel['txtusername']);
        }
        $user_audit = $audituserlist->sql_admin_user($sel);
        $this->tpl->assign('userlist',$user_audit);
        $this->tpl->display("audit/user_list_audit.html");
    }

    /**
     * 解锁
     */
    public function userUnlock(){
        $userid=$_GET['audit_id'];
        $userdata = UserDao::getUserList($userid);
        if(!empty($userid)){
            $oper=UserDao::lock_recovery(0,$userid);
             if($oper){
                   LogManager::writeAdminModifyLog($this->user['id'], $this->user['username'], '解锁管理员用户 '.$userdata[0]['username'].' 成功');
                   Handler_tool::alertAndRedirect('该管理员解锁成功！',HTTPFILEURL.'/audit/userListAudit/');
              }else{
                   Handler_tool::alertAndRedirect('该管理员解锁失败！', HTTPFILEURL.'/audit/userListAudit/');
              }
        }
        return ;
    }


//    /**
//     * 审核用户
//     */
//    public function userAudit(){
//        $audit_id=$_GET['audit_id'];
//        if(!empty($audit_id)){
//            $audituser=new AuditModule($audit_id);
//            $user=$audituser->sql_audit_user();
//            $this->tpl->assign('level', UserConfig::$userlevel[$user[0]['user']['level']]);
//            $this->tpl->assign('detail', $user);
//            $this->tpl->assign('userid', $user[0]['id']);
//        }
//        if($this->method == "POST"){
//            $audit_id=$_POST['audit_id'];
//            $type=$_POST['type'];
//            $user['is_audit']=$_POST['is_audit'];//用户权限
//            $user['login_land']=$_POST['login_land'];//用户登陆方式
//            $upAudit=new AuditModule($audit_id);
//            $return=$upAudit->sql_update_user_audit($type,$user);
//            if($return['type'] == "1"){
//                  UserDao::sqlDelUserBak($return['id']);
//                  $log=LogManager::updateAuditLog($return['log_id'],$this->user['id'],$this->user['username'],1);
//                  Handler_tool::alertAndRedirect('该用户审核完成！', HTTPFILEURL.'/audit/userListAudit/');
//            }else{
//                 $log=LogManager::updateAuditLog($return['log_id'],$this->user['id'],$this->user['username'],2);
//                 Handler_tool::alertAndRedirect('该用户审核失败！', HTTPFILEURL.'/audit/userListAudit/');
//            }
//        }
//        $this->tpl->display("audit/user_audit.html");
//    }
}

?>